package com.siyoumi.modules.user.web;

import com.siyoumi.controller.WxAppApiController;
import com.siyoumi.modules.user.service.SvcSysUser;
import com.siyoumi.modules.user.vo.SysUserEdit;
import com.siyoumi.modules.user.vo.SysUserEditPwd;
import com.siyoumi.util.XReturn;
import com.siyoumi.validator.XValidator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/wxapp/user/api")
public class ApiUser
        extends WxAppApiController {

    @PostMapping("/user_edit")
    public XReturn userEdit(@Validated SysUserEdit vo, BindingResult result) {
        //统一验证
        XValidator.getResult(result, true);

        vo.setUid(getUid());
        return SvcSysUser.getBean().userEdit(vo);
    }

    @PostMapping("/user_edit_pwd")
    public XReturn userEditPwd(@Validated SysUserEditPwd vo, BindingResult result) {
        //统一验证
        XValidator.getResult(result, true);

        vo.setUid(getUid());
        return SvcSysUser.getBean().userEditPwd(vo);
    }
}
